package com.ly.web.controller.activiti;

import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.heart.domain.dto.ActTaskCompleteDto;
import com.ly.heart.domain.dto.ActTaskQueryDto;
import com.ly.common.core.domain.BaseVo;
import com.ly.heart.service.IActModelBusinessService;
import com.ly.heart.service.IActModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "actTask", tags = "流程任务")
@RestController
@RequestMapping("/actTask")
public class ActTaskController extends BaseController {

    @Resource
    private IActModelService actModelService;
    @Resource
    private IActModelBusinessService actModelBusinessService;


    @PostMapping("/todo")
    @ApiOperation("待办任务列表")
    public AjaxResult getTasksByRoleId(@RequestBody ActTaskQueryDto queryDto){
        return actModelService.getTasksByRoleId(queryDto);
    }

    @PostMapping("/complete")
    @ApiOperation("已办任务列表")
    public  AjaxResult getCompletedTasksByRoleId(@RequestBody ActTaskQueryDto queryDto){
        return actModelService.getCompletedTasksByRoleId(queryDto);
    }

    @PostMapping("/myself")
    @ApiOperation("我发起的任务列表")
    public AjaxResult getTaskByUserId(@RequestBody BaseVo baseVo){
        return actModelService.getTaskByUserId(baseVo);
    }

    @PostMapping("/done")
    @ApiOperation("流程审批操作")
    public AjaxResult completeTaskByTaskId(@RequestBody ActTaskCompleteDto completeDto){
        return actModelService.completeTaskByTaskId(completeDto);
    }

    @PostMapping("/fromData")
    @ApiOperation("根据实例id获取表单数据")
    public AjaxResult getBusinessDataByInstanceId(@RequestParam("instanceId") String instanceId){
        return actModelService.getBusinessDataByInstanceId(instanceId);
    }

    @PostMapping("/process")
    @ApiOperation("根据实例id获取流程进度")
    public AjaxResult getTaskCommentByInstanceId(@RequestParam("instanceId") String instanceId){
        return actModelBusinessService.getTaskCommentByInstanceId(instanceId);
    }

    @PostMapping("/tasks")
    @ApiOperation("根据实例id获取所有的任务")
    public AjaxResult getTasksByInstanceId(@RequestParam("instanceId") String instanceId){
        return actModelService.getTasksByInstanceId(instanceId);
    }

//    @ApiOperation( "新增请假申请" )
//    @PostMapping
//    public AjaxResult add (@RequestBody WorkflowLeave workflowLeave) {
//        return toAjax ( actModelBusinessService.insertWorkflowLeave ( workflowLeave ) );
//    }


}
